#pragma once
#include "helper.hpp"
#include <iostream>
#include <thread>

namespace ns_log
{
    static const std::string remote_conf_file = "/home/wzs/weblog/remote/client_conf/remote.conf";

    struct LogLevel
    {
        enum class value
        {
            UNKNOWN = 0,
            DEBUG,
            INFO,
            WARNING,
            ERROR,
            FATAL,
            OFF
        };
        static std::string LogLevel_Name(value level)
        {
            switch (level)
            {
            case value::DEBUG:
                return "DEBUG";
            case value::INFO:
                return "INFO";
            case value::WARNING:
                return "WARNING";
            case value::ERROR:
                return "ERROR";
            case value::FATAL:
                return "FATAL";
            case value::OFF:
                return "OFF";
            }
            return "UNKNOWN";
        }
    };

    struct LogMessage
    {
        using ptr = std::shared_ptr<LogMessage>;
        LogMessage() = default;
        LogMessage(LogLevel::value level, const std::string &file, int line, const std::string &logger_name, const std::string &body)
            : _level(level), _time(ns_helper::DateHelper::now()), _file(file), _line(line), _logger_name(logger_name), _body(body), _thread_id(std::this_thread::get_id()) {}

        size_t sz()
        {
            size_t ans = LogLevel::LogLevel_Name(_level).size() + std::to_string(_time).size() + _file.size() + 4 + _logger_name.size() + _body.size();
            std::ostringstream oss;
            oss << _thread_id;
            ans += oss.str().size();
            return ans;
        }

        LogLevel::value _level;
        time_t _time;
        std::string _file;
        int _line;
        std::thread::id _thread_id;
        std::string _logger_name;
        std::string _body;
    };

    enum class LoggerType
    {
        SYNC,
        ASYNC
    };

    enum class AsyncType
    {
        ASYNC_SAFE,
        ASYNC_UNSAFE
    };

}
